package com.ms.platform.generator.rest;

import java.util.List;

/**
 * ${DESCRIPTION}
 */
public class TableResultResponse<T> {

	TableData<T> data;
	private int status = 200;
	private String message;
	private long srvTime = System.currentTimeMillis();

	private Object obj = null;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public long getSrvTime() {
		return srvTime;
	}

	public void setSrvTime(long srvTime) {
		this.srvTime = srvTime;
	}

	/**
	 * @return the obj
	 */
	public Object getObj() {
		return obj;
	}

	/**
	 * @param obj the obj to set
	 */
	public void setObj(Object obj) {
		this.obj = obj;
	}

	public TableResultResponse(long total, List<T> rows) {
		this.data = new TableData<T>(total, rows);
	}

	public TableResultResponse() {
		this.data = new TableData<T>();
	}

	TableResultResponse<T> total(int total) {
		this.data.setTotal(total);
		return this;
	}

	TableResultResponse<T> total(List<T> rows) {
		this.data.setRows(rows);
		return this;
	}

	public TableData<T> getData() {
		return data;
	}

	public void setData(TableData<T> data) {
		this.data = data;
	}

	public class TableData<T> {
		long total;
		List<T> rows;

		public TableData(long total, List<T> rows) {
			this.total = total;
			this.rows = rows;
		}

		public TableData() {
		}

		public long getTotal() {
			return total;
		}

		public void setTotal(long total) {
			this.total = total;
		}

		public List<T> getRows() {
			return rows;
		}

		public void setRows(List<T> rows) {
			this.rows = rows;
		}
	}
}
